mod api;
mod entity;
mod middleware;
mod config;

pub const COOKIE_NAME: &str = "blog_session";
pub const COOKIE: &str = "cookie";
pub const WEB: &str = "web";

use crate::api::admin::Admin;
use crate::middleware::global;
use hypers::prelude::{Result, Router,StaticDir};

#[tokio::main]
async fn main() -> Result<()> {
    let mut root = Router::default();
    //root.get(r#"{*path:/(js|css|images)/.+\.(js|css|webp)/}"#, StaticDir::new("static"));
    //root.get("/{*p}", StaticDir::new("static"));
    root.hook_single(global, "/{*p}");
    root.push(Admin);
    println!("root = {:#?}", root);
    let listener = hypers::TcpListener::bind("127.0.0.1:7878").await?;
    hypers::listen(root, listener).await
}
